<template>
	<view>
		<view style="display: flex;align-items: center;justify-content: space-between;padding: 30upx;">
			<text>开启</text>
			<image src="../static/kaiqi.png" mode="" style="width: 50upx;height: 50upx;" v-if="info.is_message == 1">
			</image>
			<image src="../static/bbi.png" mode="" style="width: 50upx;height: 50upx;" v-else @click="kaiqi()"></image>
		</view>
		<view style="display: flex;align-items: center;justify-content: space-between;padding: 30upx;">
			<view class="" style="display: flex;flex-direction: column;">
				<text>关闭</text>
				<text style="color: #999999;font-size: 24upx;padding-top: 20upx;">不允许任何人私信我</text>
			</view>
			<image src="../static/bbi.png" mode="" style="width: 50upx;height: 50upx;" v-if="info.is_message == 1"
				@click="guanbi()"></image>
			<image src="../static/kaiqi.png" mode="" style="width: 50upx;height: 50upx;" v-else></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {}
			}
		},
		onLoad() {
			this.$http.getreadprofile().then(res => {
				console.log(res, "微信登录没有走这里吗")
				this.info = res.data

			})
		},
		methods: {
			kaiqi() {

				var type_name = 'is_message'

				var type_id = 1

				this.$http.yinsiset({
					type_name,
					type_id
				}).then(res => {
					if (res.status == 200) {
						uni.showToast({
							title: '设置成功',
							icon: 'none'
						})
						this.info.is_message = 1
						this.serviceHotline = res.data.serviceHotline;

					}
				})
			},
			guanbi() {
				this.info.is_message = 0
				var type_name = 'is_message'
				var type_id = 0
				this.$http.yinsiset({
					type_name,
					type_id
				}).then(res => {
					if (res.status == 200) {
						uni.showToast({
							title: '设置成功',
							icon: 'none'
						})
						this.serviceHotline = res.data.serviceHotline;

					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	uni-page-body {
		background-color: #fff;
	}
</style>
